<html>
    <head>
        <title>Simple</title>
        <link type="text/css" rel="Stylesheet" href="jquery.validity.css" />
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="jquery.validity.js"></script>
        <script type="text/javascript">
			function setup() {
				$.validity.setup({scrollTo:true});
                for(var i = 0; i < 8; i++)
					$('<input/><br/>')
						.find('input')
							.attr('type', 'text')
							.attr('id', 'i' + i)
							.attr('name', 'i' + i)
						.end()
						.appendTo('body');
			}
			
			var succeed = true;
			
			var tests = {
				"Require Test":function(){
					$('input:odd').val('a value');
					$.validity.start();
					$('input').require();
					$.validity.end();
				},
                "Match Integer Test":function(){
                    var values = [
                        '', '4', '4444444444', '-12', '3.14', '1.312e5', 'not a number', '123abc'
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').match('integer');
                    $.validity.end();
                },
                "Match Number Test":function(){
                    var values = [
                        '', '4', '4444444444', '-12', '3.14', '1.312e5', 'not a number', '123abc'
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').match('number');
                    $.validity.end();
                },
                "Range Test":function(){
                    var values = [
                        1, 4, 6, 11, 18, 20, 22, 103
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').range(10, 20);
                    $.validity.end();
                },
                "Max Length Test":function(){
                    var values = [
                        'yes', 'yesss', 'yessssssss', 'yesssssssssssss', 'yesssssssssssssssssssss', 'yeahhhhhhhhhhhhhhhhhh', 'ahhahahahahahahahahahahahh', 'grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr'
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').maxLength(10);
                    $.validity.end();
                },
                "Equal Test 1 (Should succeed)":function(){
                    var values = [
                        1,1,1,1,1,1,1,1
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').equal();
                    $.validity.end();
                },
                "Equal Test 2 (Should fail)":function(){
                    var values = [
                        1,1,1,'Ugly Duckling',1,1,1,1
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').equal();
                    $.validity.end();
                },
                "Distinct Test 1 (Should succeed)":function(){
                    var values = [
                        1,2,3,4,5,6,7,8
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').distinct();
                    $.validity.end();
                },
                "Distinct Test 2 (Should fail)":function(){
                    var values = [
                        1,2,3,4,1,6,7,8
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').distinct();
                    $.validity.end();
                },
                "Sum Test 1 (Should succeed)":function(){
                    var values = [
                        25,25,25,25,25,25,25,25
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').sum(200);
                    $.validity.end();
                },
                "Sum Test 2 (Should fail)":function(){
                    var values = [
                        5,12,5,7,5,6,87,5
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').sum(200);
                    $.validity.end();
                },
                "Sum Test 3 (Should fail)":function(){
                    var values = [
                        5,12,5,7,5,6,837,5
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').sum(200);
                    $.validity.end();
                },
                "Sum Max Test 1 (Should succeed)":function(){
                    var values = [
                        25,25,25,25,25,25,25,25
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').sumMax(200);
                    $.validity.end();
                },
                "Sum Max Test 2 (Should succeed)":function(){
                    var values = [
                        5,12,5,7,5,6,87,5
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').sumMax(200);
                    $.validity.end();
                },
                "Sum Max Test 3 (Should fail)":function(){
                    var values = [
                        5,12,5,7,5,6,837,5
                    ];
                    $('input').each(function(i){
                        this.value = values[i];
                    });
                    $.validity.start();
                    $('input').sumMax(200);
                    $.validity.end();
                }
			};
			
			$(function() { 
				for (var test in tests) {
					for(var om in $.validity.outputs) {
                        alert("About to do " + test +"\nUsing output mode: " + om);
                        $.validity.start();
                        $.validity.end();
                        $.validity.setup({outputMode:om});
                        $('input').val('');
                        tests[test]();
                    }
				}
            });
        </script>
    </head>
    <body>
        <input type="text" name="i0" id="i0" /><br />
        <input type="text" name="i1" id="i1" /><br />
        <input type="text" name="i2" id="i2" /><br />
        <input type="text" name="i3" id="i3" /><br />
        <input type="text" name="i4" id="i4" /><br />
        <input type="text" name="i5" id="i5" /><br />
        <input type="text" name="i6" id="i6" /><br />
        <input type="text" name="i7" id="i7" /><br />
        <div id="validity-summary-container">
          Summary:
          <ul id="validity-summary-output"></ul>
        </div>
    </body>
</html>
